package cn.springmvc.test;

import java.util.*;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
 * Hello world!
 *
 */
public class App 
{
	public static void main(String[] args) {
		List<String> list = new ArrayList<String>();
		list.add("aaa");
		list.add("bbb");
		list.add("ccc");
		JSONArray array = JSONArray.fromObject(list);
		System.out.println(array.toString());
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("name", "json");
		map.put("bool", Boolean.TRUE);
		map.put("int", new Integer(1));
		map.put("arr", new String[] { "a", "b" });
		map.put("func", "function(i){ return this.arr[i]; }");
		JSONObject json = JSONObject.fromObject(map);
		System.out.println("Json object:" + json.toString());
		
		ProcInstEntity entity = new ProcInstEntity();
		entity.setId("id1");
		entity.setName("name1");
		JSONObject obj = JSONObject.fromObject(entity);
		System.out.println("obj:" + obj);
		String testStr = obj.toString();
		JSONObject testJsonObj = JSONObject.fromObject(testStr);
		ProcInstEntity testEntity = (ProcInstEntity) JSONObject.toBean(testJsonObj, ProcInstEntity.class);
		System.out.println(testEntity.getName());
	}

}